At present, cloud computing starts to be widely applied in various fields. In the cloud computing manner, a method for dynamically adjusting a resource is adopted to adjust resource allocation according to a requirement of a service for a resource. When a service requires a resource, a resource is allocated to the service. When the service does not require the resource, the allocated resource is reclaimed, thereby improving resource utilization and reducing hardware costs and management costs.
In an existing method for dynamically adjusting a resource, when the amount of user requests for a service reaches a capability threshold of a current resource of the service, a new resource is allocated to the service. In addition, a new service request is routed to the new resource for processing, and a currently existing service session remains on the original resource for processing. For a session-type service, durations of sessions of the service vary, and some sessions have a long duration, and these sessions may affect an original scheduling policy. For example, in a case of routing based on number segments, when a number segment processed by a resource node is changed, a currently existing service session still remains on the node for processing. Therefore, the node still needs to process a session beyond the number segment after the number segment is changed. This results in a scheduling error. In addition, during resource reclaiming, a service is allowed to release a resource only after service running on the current resource is completed, that is, no user uses the service. As a result, the resource cannot be released for a long time. In conclusion, the existing method for dynamically adjusting a resource features low correctness and low resource utilization.